package com.jt.controller;

import com.jt.pojo.Rights;
import com.jt.service.RightsService;
import com.jt.vo.SysResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author 刘昱江
 * 时间 2021/2/18
 */
@RestController
@CrossOrigin
@RequestMapping("/rights")
public class RightsController {

    @Autowired
    private RightsService rightsService;

    /**
     * 获取菜单列表
     */
    @GetMapping("/getRightsList")
    public SysResult getRightsList(){

        List<Rights> menuList = rightsService.getRightsList();
        return SysResult.success(menuList);
    }

    /**
     * 获取权限菜单
     * URL地址: getRightsListAll
     * 参数:  无
     * 返回值: SysResult对象
     */
    @GetMapping("/getRightsListAll")
    public SysResult getRightsListAll(){

        List<Rights> rightList = rightsService.getRightsListAll();

        return SysResult.success(rightList);
    }

    /**
     * 根据角色ID 查询用户三级权限信息
     * URL: http://localhost:8091/rights/getThreeRightsIds?roleId=1
     * 参数: roleId=1
     * 返回值: SysResult对象
     */
    @GetMapping("/getThreeRightsIds")
    public SysResult getThreeRightsIds(Integer roleId){

        List<Integer> rightsIds = rightsService.getThreeRightsIds(roleId);
        return SysResult.success(rightsIds);
    }
}
